//
//  UIButton+ZZBnt.m
//  Sina
//
//  Created by 张卓 on 2017/1/17.
//  Copyright © 2017年 ZZ. All rights reserved.
//

#import "UIButton+ZZBnt.h"

@implementation UIButton (ZZBnt)
+ (UIButton*)leftBntWith:(NSString*)imageName andTitle:(NSString*)title andTarget:(nullable id)target andAction:(nullable SEL)action {
    UIButton *bnt = [[UIButton alloc]init];
    if(imageName != nil){
        [bnt setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
        [bnt setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",imageName]] forState:UIControlStateHighlighted];
    }
    if(title != nil){
        [bnt setTitle:title forState:UIControlStateNormal];
        [bnt setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
        [bnt setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
//        btn.titleLabel.font = UIFont.systemFont(ofSize: 15)
        bnt.font = [UIFont systemFontOfSize:15];
    }
    
    [bnt addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [bnt sizeToFit];
    
    return bnt;
}

@end
